package com.ds.common.org.expression.person;

import java.util.Stack;

import com.ds.common.expression.ParseException;
import com.ds.common.expression.function.Function;
import com.ds.org.Person;

 /** 
 * <p>Title: JDSORG组织机构中间件</p>
 * <p>Description: </p>
 * <p>Copyright: jds Copyright (c) 2003-2008</p>
 * <p>Company: www.justdos.net</p>
 * @author lxl
 * @version 2.0
 */
public class GetPersonEmail extends Function {
	public GetPersonEmail() {
		numberOfParameters = 1;
	}

	public void run(Stack stack) throws ParseException
	{
		checkStack(stack); // check the stack

		stack.push(perform(stack.pop()));
	}

	protected String perform(Object param1) throws ParseException {
		if (param1 == null) {
			return null;
		}
		if (param1 instanceof Person) {
			Person person = (Person)param1;
			return person.getEmail();
		}
		throw new ParseException("Invalid parameter type in:" + this.getClass().getName() + ", param1 is " + param1.getClass().getName());
	}
}
